package com.example.demo.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

@Aspect
@Component
@Slf4j
public class RecordOpenidAspect {
    @Pointcut("execution(public * com.example.demo.controller.*.*(..))&&"+"!execution(public * com.example.demo.controller.WeiXinController.*(..))")
    public void verify(){} //验证
    @Before("verify()")
    public void doerify() {    //方法的具体实现
//        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//        String openid = (String)attributes.getAttribute("openid",0);  //request请求。
//        System.out.println();
    }
}
